package com.smart_environmental_protection.controller;

import com.smart_environmental_protection.pojo.Store;
import com.smart_environmental_protection.pojo.Types;
import com.smart_environmental_protection.service.TypesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TypesController {
    @Resource
    private TypesService typesService;

    @GetMapping({"/type/list"})
    public Map<String ,Object> typeList(){
        Map map=new HashMap<String ,Object>();
        List<Types> typesList=typesService.typeList();
        if (typesList!=null){
            map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("rows",typesList);
        }else {
            map.put("success",false);
            map.put("msg","失败");
        }


        return map;
    }

    @RequestMapping({"/type/list{parentId}"})
    public Map<String ,Object> types(@PathVariable Integer  parentId){
        Map map=new HashMap<String ,Object>();
        List<Types> typesList=typesService.typess(parentId);
        if (typesList!=null){
            map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("rows",typesList);
        }else {
            map.put("success",false);
            map.put("msg","失败");
        }


        return map;
    }

}
